"""
https://leetcode.cn/problems/display-the-first-three-rows/description/?envType=study-plan-v2&envId=introduction-to-pandas&lang=pythondata

2879. 显示前三行
简单
premium lock icon
相关企业
提示
DataFrame: employees
+-------------+--------+
| Column Name | Type   |
+-------------+--------+
| employee_id | int    |
| name        | object |
| department  | object |
| salary      | int    |
+-------------+--------+
编写一个解决方案，显示这个 DataFrame 的 前  3 行。

 

示例 1:

输入：
DataFrame employees
+-------------+-----------+-----------------------+--------+
| employee_id | name      | department            | salary |
+-------------+-----------+-----------------------+--------+
| 3           | Bob       | Operations            | 48675  |
| 90          | Alice     | Sales                 | 11096  |
| 9           | Tatiana   | Engineering           | 33805  |
| 60          | Annabelle | InformationTechnology | 37678  |
| 49          | Jonathan  | HumanResources        | 23793  |
| 43          | Khaled    | Administration        | 40454  |
+-------------+-----------+-----------------------+--------+
输出：
+-------------+---------+-------------+--------+
| employee_id | name    | department  | salary |
+-------------+---------+-------------+--------+
| 3           | Bob     | Operations  | 48675  |
| 90          | Alice   | Sales       | 11096  |
| 9           | Tatiana | Engineering | 33805  |
+-------------+---------+-------------+--------+
解释：
只有前 3 行被显示。
"""

import pandas as pd

def selectFirstRows(employees: pd.DataFrame) -> pd.DataFrame:
    return employees.head(3)

if __name__ == "__main__":
    employees = pd.DataFrame([
      [3, 'Bob', 'Operations', 48675],
      [90, 'Alice', 'Sales', 11096],
      [9, 'Tatiana', 'Engineering', 33805],
      [60, 'Annabelle', 'InformationTechnology', 37678],
      [49, 'Jonathan', 'HumanResources', 23793],
    ])
    print(selectFirstRows(employees))